import os

from sqlalchemy import create_engine, Column, Integer, String, DateTime
from sqlalchemy.orm import sessionmaker, declarative_base

SQL_ECHO = False
DATABASE_URL = os.environ.get("DATABASE_URL", "mysql+pymysql://localhost/test")
engine = create_engine(DATABASE_URL, echo=SQL_ECHO)


Base = declarative_base()


class Truth(Base):
    __tablename__ = "trump"

    id = Column(Integer, primary_key=True, autoincrement=True)
    content = Column(String)
    content_zh = Column(String)
    document_id = Column(String)
    created_at = Column(DateTime)
    image_url = Column(String)
    status = Column(String)


class Network(Base):
    __tablename__ = "network"

    id = Column(Integer, primary_key=True, autoincrement=True)
    ip_range = Column(String)
    created_at = Column(DateTime)
    updated_at = Column(DateTime)


class Server(Base):
    __tablename__ = "server"

    id = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String)
    ip = Column(String)
    uuid = Column(String)
    status = Column(String)
    mac = Column(String)
    vendor = Column(String)
    manage_status = Column(String)
    network_id = Column(Integer)
    created_at = Column(DateTime)
    updated_at = Column(DateTime)


Session = sessionmaker(bind=engine)
